﻿/*  CamHelper (See http://camhelper.codeplex.com/ or https://bitbucket.org/AndiKS/camhelper for more Info)
    Copyright (C) 2011 Andreas Wimmer

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

using CamHelper.Engine;
using CamHelper.Facade;
using CamHelper.Facade.TopSolid.Interfaces;
using CamHelper.Worker;
using Ninject;
using Ninject.MockingKernel.RhinoMock;
using NUnit.Framework;
using Rhino.Mocks;

namespace CamHelper.Tests.Worker
{
    [TestFixture]
    public class InsertDataWorkerTest
    {
        [Test]
        public void Action_SourceType_Environment_SourceName_UserName_TargetType_Field_TargetName_Author()
        {
            string user = "The Test Username";

            var comDocMock = MockRepository.GenerateMock<ITSDocument>();
            comDocMock.Expect(x => x.Author = user);
            var envMock = MockRepository.GenerateMock<IEnvironmentWrap>();
            envMock.Expect(x => x.UserName).Return(user);

            var kernel = new RhinoMocksMockingKernel();
            kernel.Bind<ITopSolidDocument>().To<TopSolidDocument>();
            kernel.Bind<ITSDocument>().ToConstant(comDocMock);
            kernel.Bind<IEnvironmentWrap>().ToConstant(envMock);

            var worker = kernel.Get<InsertDataWorker>();
            worker.Action("Environment", "UserName", "Field", "Author");

            envMock.VerifyAllExpectations();
            comDocMock.VerifyAllExpectations();
        }
    }
}
